﻿﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>

  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/report">报表</a></li>
          <li class="active">报表</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>报表&nbsp;-&nbsp;学员报表</span></h2>
              <div class="pull-right">
                <c:choose>
                  <c:when test="${not empty currentPrincipal.site}">
                    <span class="current-branchCode">${currentPrincipal.site.name}</span>
                  </c:when>
                  <c:otherwise>
                    <select name="site">
                      <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                        <option value="${site.id}" ${site.id == selectSite.id ? 'selected' : ''}>${site.name}</option>
                      </c:forEach>
                    </select>
                  </c:otherwise>
                </c:choose>
              </div>
            </div>
          </div>
          
          <div class="form-horizontal clearfix" style="margin-bottom: 20px">
            <div class="btn-group pull-right">
              <c:if test="${not empty selectSite}">
                <a href="${ctx.host}/student-reports/export?site=${selectSite.id}" title="" class="btn btn-default x-btn btn-shadow btn-shadow-default">
                  <i class="glyphicon glyphicon-arrow-down"></i>&nbsp;&nbsp;导出
                </a>
              </c:if>
            </div>
          </div>
          
            
          <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
            <thead>
              <tr>
                <th>学员</th>
                <th>课程/购买时间</th>
                <th>已上课时</th>
                <th>冻结状态</th>
                <th>冻结起始时间</th>
                <th>有效期剩余天数</th>
                <th>结营时间</th>
                <th class="text-center">操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="result" items="${courseRounds}">
                <c:forEach var="courseRound" items="${result.value}" varStatus="status">
	                <tr>
	                  <c:if test="${status.index == 0}">
	                    <th rowspan="${fn:length(result.value)}">${persist.student(result.key).name}</th>
	                  </c:if>
	                  <td>
	                  ${courseRound.course.name}<br/>
	                  <fmt:formatDate value="${courseRound.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
	                  </td>
	                  <td>${courseRound.finished}</td>
	                  <td>${courseRound.holdDate == null ? '未冻结' : '已冻结'}</td>
	                  <td>
	                    <c:if test="${not empty courseRound.holdDate}">
	                       <fmt:formatDate value="${courseRound.holdDate}" pattern="yyyy-MM-dd HH:mm:ss"/><br />
	                    </c:if>
	                  </td>
	                  <td>${courseRound.surplusDays}</td>
	                  <td><fmt:formatDate value="${courseRound.effectiveEnd}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
	                  <td class="text-center">
	                    <a href="${ctx.host}/student-reports/${courseRound.id}" data-target="#" data-toggle="modal">详情</a>
	                  </td>
	                </tr>
                </c:forEach>
              </c:forEach>
            </tbody>
          </table>
          
        </div>

      </div>

    </div>

  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/report/student-report.js">
    <script type="text/javascript">
      require(['page/report/student-report'], function(page) {
        page.init()
      })
    </script>
  </d:resource>
  
</body>
</html>